home *** CD-ROM | disk | FTP | other *** search
/ PC Shareware 1997 February / PC Shareware 1997-02.iso / programy / envlp122 / envelop.5 / Tools / Arsenal / tools / readero / readero.eto < prev    next >
Text File  |  1996-03-15  |  10KB  |  334 lines

  1. Type EroExplorer From Form
  2.   Type imgPicture From Image
  3.     Dim bitmap1 As New Bitmap
  4.   End Type
  5.   Dim lbFileContents As New ListBox
  6.   Dim txtFileName As New TextBox
  7.   Dim btnReadFile As New Button
  8.   Dim binfile As New BinaryFile
  9.   Type lblImageStats From Label
  10.     Dim font1 As New Font
  11.   End Type
  12.   Dim cbFit As New CheckBox
  13.   Dim Label1 As New Label
  14.   Dim Label2 As New Label
  15.   Dim Label3 As New Label
  16.   Type menubar1 From MenuBar
  17.     Dim Popup1 As New PopupMenu
  18.     Dim Popup2 As New PopupMenu
  19.   End Type
  20.   Dim helpfile As New HelpFile
  21.   Dim SampleName As String
  22.   Dim SampleDir As String
  23.  
  24.   ' METHODS for object: EroExplorer
  25.   Sub btnReadFile_Click()
  26.     If txtFileName.Text = "" Then 
  27.       InfoBox.Message("Warning", "No ERO filename has been specified.")
  28.     Else 
  29.       Dim nextId As Long
  30.       ' Clear the ResID list
  31.       lbFileContents.Clear
  32.       ' Read the filename into the BinaryFile object
  33.       ResIdReader.Reset(txtFileName.Text)
  34.       ' Populate the list with ResID numbers
  35.       Do
  36.         nextId = ResIdReader.NextResId()
  37.         If (nextId <> -1) Then lbFileContents.AddItem(nextId)
  38.       Loop While nextId <> -1
  39.       ' Select the first ResID on the list
  40.       lbFileContents.ListIndex = 0
  41.     End If
  42.   End Sub
  43.  
  44.   Sub cbFit_Click()
  45.     If cbFit.Value Then 
  46.       imgPicture.ResizeMode = "Fit"
  47.       imgPicture.InitCropRect
  48.     Else 
  49.       imgPicture.ResizeMode = "Clip"
  50.       imgPicture.ScaleX = 1.0
  51.       imgPicture.ScaleY = 1.0
  52.     End If
  53.   End Sub
  54.  
  55.   Sub Destruct()
  56.     helpfile.Quit
  57.   End Sub
  58.  
  59.   Sub ExitApplication_Click
  60.     helpfile.Quit
  61.     UnloadForm
  62.   End Sub
  63.  
  64.   Sub HelpContents_Click()
  65.     helpfile.Contents
  66.   End Sub
  67.  
  68.   Function HelpContents_Enable() As Integer
  69.     HelpContents_Enable = helpfile.Exists
  70.   End Function
  71.  
  72.   Sub InitHelpFile
  73.     helpfile.FileName = SampleDir & SampleName & ".hlp"
  74.   End Sub
  75.  
  76.   Sub lbFileContents_Click()
  77.     imgPicture.Picture.LoadType = "MemoryBased"
  78.     imgPicture.Picture.FileName = txtFileName.Text
  79.     imgPicture.Picture.ResId = lbFileContents.List(lbFileContents.ListIndex)
  80.   
  81.     ' Configure the image control to show "fitted" image or 1:1 scale image.
  82.     cbFit_Click()
  83.     imgPicture.Refresh
  84.   
  85.     lblImageStats.Text = imgPicture.Picture.Width & " x " & imgPicture.Picture.Height & " x " & imgPicture.Picture.NumColors
  86.   End Sub
  87.  
  88.   Sub OpenEROFile_Click()
  89.     Dim openDlg as new OpenDialog
  90.     openDlg.DefaultExtension = "ero"
  91.     openDlg.FileMustExist = False
  92.     openDlg.Filter = "Envelop Text Resource files (*.ero)|*.ero|All files (*.*)|*.*|"
  93.     openDlg.NoChangeDir = True
  94.     openDlg.Title = "Choose Envelop Text Resource File"
  95.     If openDlg.Execute = IDOK Then 
  96.       txtFileName.Text = openDlg.FileName
  97.       btnReadFile_Click
  98.     End If
  99.   End Sub
  100.  
  101.   Sub Preload
  102.     SetSampleDir
  103.     InitHelpFile
  104.     ResetApplication_Click
  105.     Show
  106.   End Sub
  107.  
  108.   Sub ResetApplication_Click()
  109.     ' Clear and reset the contents of the ERO Explorer
  110.     txtFileName.Text = ""
  111.     lbFileContents.Clear
  112.     lblImageStats.Text = ""
  113.     cbFit.Value = False
  114.     imgPicture.Picture.LoadType = "FileBased"
  115.     imgPicture.Picture.FileName = ""
  116.     imgPicture.Refresh
  117.   End Sub
  118.  
  119.   Sub Resize()
  120.     Dim Border As Integer
  121.     Border = 150
  122.   
  123.     btnReadFile.Left = ScaleWidth - btnReadFile.Width - Border
  124.     txtFileName.Width = btnReadFile.Left - txtFileName.Left - Border
  125.     lbFileContents.Height = ScaleHeight - lbFileContents.Top - Border
  126.     imgPicture.Width = ScaleWidth - imgPicture.Left - Border
  127.     imgPicture.Height = ScaleHeight - imgPicture.Top - Border
  128.     cbFit.Left = imgPicture.Left + imgPicture.Width - cbFit.Width
  129.     lblImageStats.Width = cbFit.Left - lblImageStats.Left
  130.   
  131.     lblImageStats.Refresh
  132.     txtFileName.Refresh
  133.   End Sub
  134.  
  135.   Sub SaveAsBinary
  136.     ModuleManager.ModuleContaining(Me).SaveAs(SampleDir & SampleName & ".ebo", False)
  137.   End Sub
  138.  
  139.   Sub SaveAsBitmapFile_Click()
  140.     Dim saveasDlg As New SaveAsDialog
  141.     saveasDlg.DefaultExtension = "bmp"
  142.     saveasDlg.Filter = "Bitmap files (*.bmp)|*.bmp|All files (*.*)|*.*|"
  143.     saveasDlg.NoChangeDir = True
  144.     saveasDlg.Title = "Select Bitmap File"
  145.     If saveasDlg.Execute = IDOK Then 
  146.       imgPicture.Picture.SaveAs(saveasDlg.FileName)
  147.     End If
  148.   End Sub
  149.  
  150.   Sub SaveAsText
  151.     ModuleManager.ModuleContaining(Me).SaveAs(SampleDir & SampleName & ".eto", True)
  152.   End Sub
  153.  
  154.   Sub SetSampleDir()
  155.     ' The purpose of this routine is to set "SampleDir", a string containing
  156.     ' the directory from which the application was loaded.  This may be useful
  157.     ' in the event any data must be saved from the application and File objects
  158.     ' were used and possibly changed our current directory.
  159.     Dim m As ObjectModule
  160.     Dim f As New File
  161.     m = ModuleManager.ModuleContaining(Me)
  162.     f.FileName = m.FileName
  163.     SampleDir = f.Path
  164.     SampleName = f.Name
  165.   End Sub
  166.  
  167.   Sub TextPreLoad()
  168.     ' Ensures the call to Load.
  169.     RequestObjectPreload(Me)
  170.   
  171.     ' Restore prerequisite objects that are shared with other
  172.     ' samples, and therefore may already be loaded.
  173.   End Sub
  174.  
  175. End Type
  176.  
  177. Type ResIdReader
  178.   Dim BinFile As New BinaryFile
  179.  
  180.   ' METHODS for object: ResIdReader
  181.   Function NextResId() As Long
  182.     dim tempInteger As Integer
  183.     dim tempLong As Long
  184.   
  185.     If (Not BinFile.IsOpen()) Then NextResId = -1 : Exit Function
  186.   
  187.     NextResId = BinFile.Position
  188.   
  189.     If (BinFile.ReadLong(tempLong) && tempLong = &H1020304) Then 
  190.       If (BinFile.ReadLong(tempLong) && tempLong = 99) Then 
  191.         ' Read Length
  192.         If (BinFile.ReadLong(tempLong)) Then 
  193.           ' We have successfully advanced to another position
  194.           BinFile.Position = BinFile.Position + tempLong
  195.           Exit Function
  196.         End If
  197.       End If
  198.     End If
  199.     ' Did not advance
  200.     NextResId = -1
  201.     BinFile.Close()
  202.   End Function
  203.  
  204.   Sub Reset(fname as String)
  205.     BinFile.FileName = fname
  206.     BinFile.OpenReadOnly()
  207.   End Sub
  208.  
  209. End Type
  210.  
  211. Type EROReader From Application
  212.   Dim AccessControl As New ACL
  213. End Type
  214.  
  215. Begin Code
  216. ' Reconstruction commands for object: EroExplorer
  217. '
  218.   With EroExplorer
  219.     .TextPreLoad()
  220.     .Caption := "ERO Explorer"
  221.     .Move(1770, 1530, 8220, 6570)
  222.     .DefaultButton := EroExplorer.btnReadFile
  223.     .MenuBar := EroExplorer.menubar1
  224.     .SampleName := "readero"
  225.     .SampleDir := "C:\envelop\arsenal\apps\readero\"
  226.     With .imgPicture
  227.       .Caption := "imgPicture"
  228.       .ZOrder := 9
  229.       .Move(2850, 1125, 5100, 4605)
  230.       .AutoInitCropRect := False
  231.       .Picture := EroExplorer.imgPicture.bitmap1
  232.       .ResizeMode := "Clip"
  233.       .ScaleX := 1
  234.       .ScaleY := 1
  235.       With .bitmap1
  236.         .Persistent := False
  237.       End With  'EroExplorer.imgPicture.bitmap1
  238.     End With  'EroExplorer.imgPicture
  239.     With .lbFileContents
  240.       .Caption := "lbFileContents"
  241.       .ZOrder := 8
  242.       .Move(150, 1125, 2565, 4590)
  243.       .Sorted := False
  244.     End With  'EroExplorer.lbFileContents
  245.     With .txtFileName
  246.       .ZOrder := 7
  247.       .Move(1200, 150, 5700, 375)
  248.     End With  'EroExplorer.txtFileName
  249.     With .btnReadFile
  250.       .Caption := "Read"
  251.       .ZOrder := 6
  252.       .Move(7050, 150, 900, 375)
  253.     End With  'EroExplorer.btnReadFile
  254.     With .binfile
  255.       .FileName := "w:\source\envelop\envelop1.ero"
  256.     End With  'EroExplorer.binfile
  257.     With .lblImageStats
  258.       .ForeColor := 0
  259.       .Font := EroExplorer.lblImageStats.font1
  260.       .ZOrder := 5
  261.       .Move(4200, 750, -3450, 300)
  262.       With .font1
  263.         .FaceName := "Arial"
  264.         .Size := 9.000000
  265.         .Bold := False
  266.         .Italic := False
  267.         .Strikethru := False
  268.       End With  'EroExplorer.lblImageStats.font1
  269.     End With  'EroExplorer.lblImageStats
  270.     With .cbFit
  271.       .Caption := "Fit"
  272.       .ZOrder := 4
  273.       .Move(7350, 750, 600, 300)
  274.     End With  'EroExplorer.cbFit
  275.     With .Label1
  276.       .Caption := "Bitmap Size:"
  277.       .ForeColor := 16711680
  278.       .ZOrder := 3
  279.       .Move(2850, 750, 1275, 300)
  280.     End With  'EroExplorer.Label1
  281.     With .Label2
  282.       .Caption := "ERO File:"
  283.       .ForeColor := 16711680
  284.       .ZOrder := 2
  285.       .Move(150, 225, 975, 300)
  286.     End With  'EroExplorer.Label2
  287.     With .Label3
  288.       .Caption := "ResID List:"
  289.       .ForeColor := 16711680
  290.       .ZOrder := 1
  291.       .Move(150, 750, 1125, 300)
  292.     End With  'EroExplorer.Label3
  293.     With .menubar1
  294.  
  295.       .InsertPopup(EroExplorer.menubar1.Popup1, "&File", -1)
  296.       .InsertPopup(EroExplorer.menubar1.Popup2, "&Help", -1)
  297.       With .Popup1
  298.  
  299.         .InsertItem("OpenEROFile", "&Open", -1)
  300.         .InsertItem("SaveAsBitmapFile", "&Save As", -1)
  301.         .InsertSeparator(-1)
  302.         .InsertItem("ResetApplication", "&Reset", -1)
  303.         .InsertSeparator(-1)
  304.         .InsertItem("ExitApplication", "&Exit", -1)
  305.       End With  'EroExplorer.menubar1.Popup1
  306.       With .Popup2
  307.  
  308.         .InsertItem("HelpContents", "&Contents", -1)
  309.       End With  'EroExplorer.menubar1.Popup2
  310.     End With  'EroExplorer.menubar1
  311.     With .helpfile
  312.       .FileName := "C:\envelop\arsenal\apps\readero\readero.hlp"
  313.     End With  'EroExplorer.helpfile
  314.   End With  'EroExplorer
  315. ' Reconstruction commands for object: ResIdReader
  316. '
  317.   With ResIdReader
  318.     With .BinFile
  319.     End With  'ResIdReader.BinFile
  320.   End With  'ResIdReader
  321. ' Reconstruction commands for object: EROReader
  322. '
  323.   With EROReader
  324.     .ModulePath := "base.ebo;win32.ebo;dialogs.ebo;tools.ebo;readero.eto"
  325.     .ProjectFileName := "C:\envelop\arsenal\apps\readero\readero.epj"
  326.     .MainForm := EroExplorer
  327.     .Path := "C:\envelop\arsenal\apps\readero\"
  328.     .EXEName := "readero"
  329.     With .AccessControl
  330.       .ObjectAccess := "R,W,C,M,P"
  331.     End With  'EROReader.AccessControl
  332.   End With  'EROReader
  333. End Code
  334.